package org.sunsys.qa.web.command.reslover;

import java.util.HashMap;

import org.sunsys.qa.web.command.QaWebCommand;
import org.sunsys.qa.web.command.UserLoginCommand;
import org.sunsys.qa.web.command.UserLogoutCommand;
import org.sunsys.qa.web.command.UserRegistrationCommand;

public class QaWebCommandResolverImpl implements QaWebCommandResolver {

	/**
	 * holds <command class instance> associated with <action>
	 */
	private HashMap<String, QaWebCommand> serviceControllersMap = null;
	
	public QaWebCommandResolverImpl() {
		serviceControllersMap = new HashMap<String, QaWebCommand>();
		
		QaWebCommand userRegistrationCommand = new UserRegistrationCommand();
		QaWebCommand userLoginCommand = new UserLoginCommand();
		QaWebCommand userLogoutCommand = new UserLogoutCommand();
		/* add command object associated with userRegistration */
		serviceControllersMap.put("userRegistration", userRegistrationCommand);
		/* add command object associated with login */
		serviceControllersMap.put("login", userLoginCommand);
		/* add command object associated with logout */
		serviceControllersMap.put("logout", userLogoutCommand);
		
		
	}
	
	@Override
	public QaWebCommand getServiceCommand(String action) {
		/* return service controller associated with the service name */
		return this.serviceControllersMap.get(action);
	}
}
